package com.chushouya.order.dto.admin.paymentlog;

import com.general.framework.core.lang.Dates;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Date;

/**
 * 支付日志列表展示DTO
 */
@ApiModel("支付日志列表信息")
@Data
public class PaymentLogListDTO {

    @ApiModelProperty("支付日志ID")
    private Long logId;

    @ApiModelProperty("订单ID")
    private Long orderId;

    @ApiModelProperty("订单编号")
    private String orderNo;

    @ApiModelProperty("商户转账单号")
    private String outBizNo;

    @ApiModelProperty("支付宝转账单号")
    private String tradeNo;

    @ApiModelProperty("支付金额")
    private BigDecimal payAmount;

    @ApiModelProperty("支付渠道")
    private String payChannel;

    @ApiModelProperty("支付渠道描述")
    private String payChannelDesc;

    @ApiModelProperty("支付类型")
    private String payType;

    @ApiModelProperty("支付类型描述")
    private String payTypeDesc;

    @ApiModelProperty("支付状态：0=待支付，1=支付成功，2=支付失败")
    private Boolean status;

    @ApiModelProperty("支付状态描述")
    private String statusDesc;

    @ApiModelProperty("支付账号ID")
    private String openId;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = Dates.FMT_FULL_TIME)
    private Date createTime;

    @ApiModelProperty("更新时间")
    @JsonFormat(pattern = Dates.FMT_FULL_TIME)
    private Date updateTime;

    /**
     * 获取支付渠道描述
     */
    public String getPayChannelDesc() {
        if (payChannel == null) {
            return "";
        }
        switch (payChannel.toLowerCase()) {
            case "alipay":
                return "支付宝";
            case "wechat":
                return "微信";
            case "unionpay":
                return "银联";
            default:
                return payChannel;
        }
    }

    /**
     * 获取支付类型描述
     */
    public String getPayTypeDesc() {
        if (payType == null) {
            return "";
        }
        switch (payType.toLowerCase()) {
            case "transfer":
                return "转账";
            case "qrcode":
                return "扫码支付";
            case "app":
                return "APP支付";
            case "h5":
                return "H5支付";
            case "jsapi":
                return "公众号支付";
            default:
                return payType;
        }
    }

    /**
     * 获取支付状态描述
     */
    public String getStatusDesc() {
        if (status == null) {
            return "未知";
        }
        if (status) {
            return "支付成功";
        } else {
            return "支付失败";
        }
    }
}
